"""
求矩阵鞍点的个数
"""

n = eval(input())
list1 = []
count = 0
for i in range(0, n):
    list1.append(list(map(int, input().split())))
for i in range(len(list1)):
    max_Xnum = list1[i][0]
    max_Y = []
    for j in range(len(list1[i])):
        if list1[i][j] > max_Xnum:
            max_Y.clear()
            max_Xnum = list1[i][j]
            max_Y.append(j)
        elif list1[i][j] == max_Xnum:
            max_Y.append(j)
    while 1:
        flag = True
        for k in range(len(list1)):
            if list1[i][max_Y[0]] > list1[k][max_Y[0]]:
                flag = False
                break
        if not flag:
            max_Y.pop(0)

        else:
            count+=1
            max_Y.pop(0)
        if len(max_Y) < 1:
            break
print(count)
